from core.report.models import *
from django.contrib import admin

class ToolAdminInline(admin.TabularInline):
    model = Tool
    extra = 1
    
class TargetAdminInline(admin.TabularInline):
    model = Target
    extra = 1

class ToolConfigAdminInline(admin.TabularInline):
    model = ToolConfig
    extra = 1
    
class ComponentAdminInline(admin.TabularInline):
    model = Component
    
class BranchAdminInline(admin.TabularInline):
    model = Branch
    extra = 1

class ToolAdmin(admin.ModelAdmin):
    list_display = ('name',)
    inlines = (ToolConfigAdminInline, )
    
class ProductAdmin(admin.ModelAdmin):
    list_display = ('name',)
    inlines = (ComponentAdminInline, BranchAdminInline)
    
class ComponentAdmin(admin.ModelAdmin):
    list_display = ('product', 'name', 'category')
    inlines = (TargetAdminInline, )

class ToolConfigAdmin(admin.ModelAdmin):
    list_display = ('tool', 'branch', 'weight')

class TargetAdmin(admin.ModelAdmin):
    list_display = ('branch', 'component', 'target_rank')

class BranchAdmin(admin.ModelAdmin):
    list_display = ('product', 'name', 'node_architect', 'status')
    inlines = (ToolConfigAdminInline, TargetAdminInline)

class RankDataAdmin(admin.ModelAdmin):
    list_display = ('component', 'tool_config', 'create_time', 'rank')

class CategoryAdmin(admin.ModelAdmin):
    list_display = ('name', )
    inlines = (ComponentAdminInline, ToolAdminInline)

admin.site.register(Category, CategoryAdmin)
admin.site.register(Product, ProductAdmin)
admin.site.register(Branch, BranchAdmin)
admin.site.register(Component, ComponentAdmin)
admin.site.register(RankData, RankDataAdmin)
admin.site.register(Tool, ToolAdmin)
admin.site.register(ToolConfig, ToolConfigAdmin)
admin.site.register(Target, TargetAdmin)
